﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Boco.Digg.Utilities
{
	public static class DateTimeExtensions
	{
		public static int ToUnixEpoch(this DateTime date)
		{
			DateTime epoch = DateTime.Parse("1970/01/01");
			TimeSpan diff = (date - epoch);
			if (diff.Seconds < 0)
				throw new ArgumentOutOfRangeException("date is before the UNIX epoch (01/01/1970)");

			return (int)diff.TotalSeconds;
		}
	}
}